package com.sunl.mall.ali.mq.util;

import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.ons.api.MessageAccessor;
import com.sunl.mall.ali.mq.model.RocketMqMessageContext;
import com.sunl.mall.ali.mq.model.order.RocketMqOrderMessageContext;
import com.sunl.mall.ali.mq.model.transaction.RocketMqTransactionMessageContext;

public class MqContextUtil {
    public static RocketMqMessageContext getMessageContext(Message message) {
        return new RocketMqMessageContext(message.getTopic(), message.getUserProperties(), MessageAccessor.getSystemProperties(message));
    }

    public static RocketMqOrderMessageContext getOrderMessageContext(Message message) {
        return new RocketMqOrderMessageContext(message.getTopic(), message.getUserProperties(), MessageAccessor.getSystemProperties(message));

    }

    public static RocketMqTransactionMessageContext getTransactionMessageContext(Message message) {
        return new RocketMqTransactionMessageContext(message.getTopic(), message.getUserProperties(), MessageAccessor.getSystemProperties(message));
    }
}
